import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.JRadioButton;
import javax.swing.JMenuItem;
import javax.swing.JCheckBoxMenuItem;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;


public class addTeacher extends JFrame {

	private JPanel contentPane;
	private JTextField iddata;
	private JTextField namedata;
	private static addTeacher frame;
	private static JRadioButton pradiobutton;
	private static JRadioButton tradiobutton;
	private String usertype;
	private JLabel label;
	private JTextField pwdata;
	private JTextField emaildata;
	private JTextField hphonedata;
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					frame = new addTeacher();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public addTeacher() {
		setAlwaysOnTop(true);
		setTitle("\uC120\uC0DD\uB2D8 / \uD559\uBD80\uBAA8 \uCD94\uAC00");
		//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 586, 193);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel name_label = new JLabel("\uC774\uB984");
		name_label.setHorizontalAlignment(SwingConstants.CENTER);
		name_label.setBounds(12, 56, 57, 15);
		contentPane.add(name_label);
		
		JLabel lblNewLabel = new JLabel("\uC5F0\uB77D\uCC98(ID)");
		lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
		lblNewLabel.setBounds(12, 24, 57, 15);
		contentPane.add(lblNewLabel);
		
		iddata = new JTextField();
		iddata.setBounds(81, 21, 150, 21);
		contentPane.add(iddata);
		iddata.setColumns(10);
		
		namedata = new JTextField();
		namedata.setBounds(81, 53, 150, 21);
		contentPane.add(namedata);
		namedata.setColumns(10);
		
		JButton ok_button = new JButton("\uD655\uC778");
		ok_button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				String sql = "insert into academy.user value ('" + iddata.getText().toString() + "','" + namedata.getText().toString() + "','" + pwdata.getText().toString() + "','"+
				usertype + "','" + emaildata.getText().toString() + "','" + hphonedata.getText().toString() + "');";
				System.out.println(sql);
				main.db.updateDB(sql);
				
				
				setVisible(false);
			}
		});
		ok_button.setBounds(342, 108, 97, 34);
		contentPane.add(ok_button);
		
		JButton cancle_button = new JButton("\uCDE8\uC18C");
		cancle_button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setVisible(false);
			}
		});
		
		ButtonGroup bg = new ButtonGroup();
		
		cancle_button.setBounds(461, 108, 97, 34);
		contentPane.add(cancle_button);
		
		pradiobutton = new JRadioButton("\uBD80\uBAA8\uB2D8");
		bg.add(pradiobutton);
		pradiobutton.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				usertype = "p";
				System.out.println(usertype);
			}
		});
		pradiobutton.setBounds(390, 53, 72, 23);
		contentPane.add(pradiobutton);
		
		tradiobutton = new JRadioButton("\uC120\uC0DD\uB2D8");
		tradiobutton.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				usertype = "t";
				System.out.println(usertype);
			}
		});
		bg.add(tradiobutton);
		tradiobutton.setBounds(463, 53, 81, 23);
		contentPane.add(tradiobutton);
		
		label = new JLabel("\uACC4\uC815 \uD0C0\uC785 \uC120\uD0DD : ");
		label.setHorizontalAlignment(SwingConstants.CENTER);
		label.setBounds(285, 57, 97, 15);
		contentPane.add(label);
		
		pwdata = new JTextField();
		pwdata.setColumns(10);
		pwdata.setBounds(394, 24, 150, 21);
		contentPane.add(pwdata);
		
		JLabel label_1 = new JLabel("\uBE44\uBC00\uBC88\uD638");
		label_1.setHorizontalAlignment(SwingConstants.CENTER);
		label_1.setBounds(285, 27, 72, 15);
		contentPane.add(label_1);
		
		emaildata = new JTextField();
		emaildata.setColumns(10);
		emaildata.setBounds(81, 84, 150, 21);
		contentPane.add(emaildata);
		
		hphonedata = new JTextField();
		hphonedata.setColumns(10);
		hphonedata.setBounds(81, 115, 150, 21);
		contentPane.add(hphonedata);
		
		JLabel lblEmail = new JLabel("E-mail");
		lblEmail.setHorizontalAlignment(SwingConstants.CENTER);
		lblEmail.setBounds(12, 87, 57, 15);
		contentPane.add(lblEmail);
		
		JLabel label_3 = new JLabel("\uC9D1\uC804\uD654\uBC88\uD638");
		label_3.setHorizontalAlignment(SwingConstants.CENTER);
		label_3.setBounds(12, 118, 72, 15);
		contentPane.add(label_3);
	}
}
